<!DOCTYPE html>
<html lang="en">
<head>
  <title>浩然金融中心管理平台</title>
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"
        name="viewport">
  <#include "/common/csslib.html">
  <script type="text/javascript">
      var userTable;
      var selectType = "${selectType!}";
  </script>
</head>
<body>
<div class="main-wrapper">
  <!-- start: MAIN CONTAINER -->
  <div class="main-container inner">
    <!-- start: PAGE -->
    <div class="main-content">
      <div class="container">
        <!-- 当前位置 begin -->
        <div class="row h-home-path">
          <div class="col-md-12">
            <ol class="breadcrumb">
              <li><i class="fa fa-home"></i>&nbsp;&nbsp;所在位置</li>
              <li>首页</li>
              <li class="active">导入用户信息</li>
            </ol>
          </div>
        </div>
        <!-- 当前位置 end -->

        <!-- 查询筛选内容 bagin -->
        <div class="row h-main-search">
          <form action="javascript:;" method="post">
            <div class="col-md-2 col-sm-2 col-xs-2 text-right">
              <label class="control-labe h-form-label" for="username">用户名称：</label>
            </div>
            <div class="col-md-2 col-sm-2 col-xs-2">
              <input class="form-control" id="username" name="username" type="text" value="">
            </div>
            <div class="pull-right h-btn-group">
              <button class="btn btn-info" onclick="UserManager.search()" type="button"><i class="fa fa-search">&nbsp;&nbsp;</i>查询
              </button>
              <button class="btn btn-default" type="reset"><i class="fa fa-mail-reply">&nbsp;&nbsp;</i>重置</button>
            </div>
          </form>
        </div>

        <!-- 表格 begin -->
        <div class="panel panel-white h-panel">
          <div class="panel-body">
            <table class="table table-striped table-bordered table-hover text-center" id="user_table"
                   style='width:100%'></table>
          </div>
        </div>
        <!-- 表格 end -->
      </div>
    </div>
    <!-- end: PAGE -->
  </div>
  <!-- end: MAIN CONTAINER -->
  <!-- 新增 end -->
  <!-- end: SUBVIEW SAMPLE CONTENTS -->
</div>
<#include "/common/jslib.html">
<script type="text/javascript">
    $(function () {
        var api = frameElement.api;
        var W = api.opener;
        UserManager = {
            init: function () {
                api.button({
                    id: 'cancel',
                    name: '关闭',
                    callback: function () {
                        W.location.reload();
                    }
                });
                api.button({
                    id: 'ok',
                    name: '确认选择',
                    callback: UserManager.selectUser
                });
            },
            search: function () {
                var queryCond = {
                    username: $("#username").val()
                };
                userTable.options.queryCond = queryCond;
                var tableId = userTable.options.tableId;
                $(tableId).DataTable().draw();
            },
            selectUser: function () {
                var securityOrgUser_select = $("input[name='securityOrgUser_select']:checked");
                if (securityOrgUser_select.length == 0) {
                    Jmts.warnTips("请选择一条记录");
                    return false;
                }
                var selectStr = "";
                if (selectType == "multiple") {
                    securityOrgUser_select.each(function (i) {
                        if (0 == i) {
                            selectStr = $(this).val();
                        } else {
                            selectStr += ("," + $(this).val());
                        }
                    });
                } else {
                    selectStr = securityOrgUser_select.val();
                }
                Jmts.confirm("确定要导入吗？", function () {
                    var url = "/securityOrgUser/importSecurityOrgUser";
                    var data = {
                        userIds: selectStr,
                        orgId: '${orgId!}'
                    }
                    Jmts.ajaxPost(url, data, function (result) {
                        if (result.success) {
                            W.Jmts.succTips(result.msg);
                        } else {
                            W.Jmts.warnTips(result.msg);
                        }
                    });
                });
                return false;
            }
        }
        UserManager.init();
    });
</script>
<!-- 弹窗下拉 -->
<script type="text/javascript">
    (function () {
        // datatable插件
        userTable = new mi.datatable({
            tableId: '#user_table',
            headerList: [
                '操作',
                '用户名称',
                '状态',
                '说明'
            ],
            headerName: [
                'operate',
                'username',
                'statusCn',
                'comment'
            ],
            ajaxUrl: '/securityUser/listUser',
            queryCond: function () {

            },
            columnDefs: [
                {targets: 0, orderable: false}
            ],
            createdRow: function (row, data, dataIndex) {
                $(row).children('td').eq(1).attr('style',
                    'text-align:left;');
            },
            dataSrc: function (data) {
                var newArr = [];
                for (var i in data) {
                    var id = data[i]['id'];
                    var str = id;
                    var operateDtr = mi.markLink({
                        className: 'js-del-row-btn',
                        txt: selectType == "multiple" ?
                            "<input type='checkBox' id='securityOrgUser_select' name='securityOrgUser_select' value='" + str + "'/>" :
                            "<input type='radio' id='securityOrgUser_select' name='securityOrgUser_select' value='" + str + "'/>",
                        data: [
                            {id: id}
                        ]
                    });
                    data[i]['operate'] = operateDtr;
                }
                return data;
            }
        });
    })();
</script>
</body>
</html>
